/**
 * 格式时间
 * @param date
 * @param fmt
 */

const formatDate = (date, fmt) => {
  let ret;
  let o = {
    "y+": date.getFullYear(),
    "M+": date.getMonth() + 1,
    "d+": date.getDate(),
    "H+": date.getHours(),
    "m+": date.getMinutes(),
    "s+": date.getSeconds(),
    "W+": date.getDay(),
  };
  for (let k in o) {
    ret = new RegExp("(" + k + ")").exec(fmt);
    if (ret) {
      let str = o[k].toString();
      str = str.padStart(2,0);
      fmt = fmt.replace(ret[1], str);
    }
  }
  return fmt;
}

// 判断是否是闰年
const leapYear = (year) => {
    if((year % 4 == 0 && year % 100 != 0) || year % 400 == 0)return true;
    return false;
  }
export {
  formatDate,
  leapYear
}